package zoo.productqnareplyboard.admin.controller;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import zoo.productqnareplyboard.admin.dao.AdminQnAProductReplyBoardDao;
import zoo.productqnareplyboard.admin.domain.AdminProductReplyBoardCommand;
import zoo.productqnareplyboard.admin.domain.AdminQboardCommand;

@Controller
public class AdminProductReplyBoardDetailController {
	private static Log log = LogFactory.getLog(AdminProductReplyBoardDetailController.class);
	
	private AdminQnAProductReplyBoardDao aqnaDao;
	
	@Autowired
	public void setMemberService(AdminQnAProductReplyBoardDao aqnaDao) {
		this.aqnaDao = aqnaDao;
	}
	
	@RequestMapping("/admin/qnadetail.do")
	public ModelAndView process(@RequestParam("bq_num") int bq_num) {

		if (log.isDebugEnabled()) {
			log.debug("qboardService : " + aqnaDao);
		}
		
		AdminQboardCommand qboard = null;
		qboard = aqnaDao.selectQBoard(bq_num);
	
		List<AdminProductReplyBoardCommand> rboard = null;
		rboard = aqnaDao.selectQnaReply(bq_num);
		
		/*
		System.out.println("큐보드: "+qboard+"알보드:"+rboard);*/
		
		ModelAndView mav = new ModelAndView();
		mav.setViewName("admin_qna_detail");
		mav.addObject("qboarddetail",qboard);
		mav.addObject("list",rboard);
			
		return mav;
	}
}
